<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude, MagicHash, ImplicitParams #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE RankNTypes, PolyKinds, DataKinds #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  GHC.Err</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 1994-2002</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  cvs-ghc@haskell.org</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  non-portable (GHC extensions)</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- The &quot;GHC.Err&quot; module defines the code for the wired-in error functions,</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- which have a special type in the compiler (with \&quot;open tyvars\&quot;).</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- We cannot define these functions in a module where they might be used</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- (e.g., &quot;GHC.Base&quot;), because the magical wired-in type will get confused</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- with what the typechecker figures out.</span><span>
</span><span id="line-22"></span><span class="hs-comment">--</span><span>
</span><span id="line-23"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Err</span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Err.html#absentErr"><span class="hs-identifier">absentErr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Err.html#error"><span class="hs-identifier">error</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier">errorWithoutStackTrace</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Err.html#undefined"><span class="hs-identifier">undefined</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#"><span class="hs-identifier">GHC.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier">Char</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#RuntimeRep"><span class="hs-identifier">RuntimeRep</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Stack.Types.html"><span class="hs-identifier">GHC.Stack.Types</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#"><span class="hs-identifier">GHC.Prim</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#"><span class="hs-identifier">GHC.Num.Integer</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- See Note [Depend on GHC.Num.Integer] in GHC.Base</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="annot"><a href="GHC.Exception.html"><span class="hs-identifier">GHC.Exception</span></a></span><span>
</span><span id="line-31"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Exception.html#errorCallWithCallStackException"><span class="hs-identifier">errorCallWithCallStackException</span></a></span><span>
</span><span id="line-32"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Exception.html#errorCallException"><span class="hs-identifier">errorCallException</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span class="hs-comment">-- | 'error' stops execution and displays an error message.</span><span>
</span><span id="line-35"></span><span class="annot"><a href="GHC.Err.html#error"><span class="hs-identifier hs-type">error</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679538321"><span class="annot"><a href="#local-6989586621679538321"><span class="hs-identifier hs-type">r</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#RuntimeRep"><span class="hs-identifier hs-type">RuntimeRep</span></a></span><span class="hs-special">)</span><span class="hs-operator">.</span><span> </span><span class="hs-keyword">forall</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679538319"><span class="annot"><a href="#local-6989586621679538319"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#TYPE"><span class="hs-identifier hs-type">TYPE</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538321"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span class="hs-operator">.</span><span>
</span><span id="line-36"></span><span>         </span><span class="annot"><a href="GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538319"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-37"></span><span id="error"><span class="annot"><span class="annottext">error :: forall a. HasCallStack =&gt; [Char] -&gt; a
</span><a href="GHC.Err.html#error"><span class="hs-identifier hs-var hs-var">error</span></a></span></span><span> </span><span id="local-6989586621679538297"><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679538297"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SomeException -&gt; a
forall b a. b -&gt; a
</span><a href="../../ghc-prim/src/GHC.Prim.html#raise%23"><span class="hs-identifier hs-var">raise#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; CallStack -&gt; SomeException
</span><a href="GHC.Exception.html#errorCallWithCallStackException"><span class="hs-identifier hs-var">errorCallWithCallStackException</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679538297"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">HasCallStack
CallStack
</span><a href="#local-6989586621679538298"><span class="hs-var">?callStack</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span>          </span><span class="hs-comment">-- Bleh, we should be using 'GHC.Stack.callStack' instead of</span><span>
</span><span id="line-39"></span><span>          </span><span class="hs-comment">-- '?callStack' here, but 'GHC.Stack.callStack' depends on</span><span>
</span><span id="line-40"></span><span>          </span><span class="hs-comment">-- 'GHC.Stack.popCallStack', which is partial and depends on</span><span>
</span><span id="line-41"></span><span>          </span><span class="hs-comment">-- 'error'.. Do as I say, not as I do.</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="hs-comment">-- | A variant of 'error' that does not produce a stack trace.</span><span>
</span><span id="line-44"></span><span class="hs-comment">--</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- @since 4.9.0.0</span><span>
</span><span id="line-46"></span><span class="annot"><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-type">errorWithoutStackTrace</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679538313"><span class="annot"><a href="#local-6989586621679538313"><span class="hs-identifier hs-type">r</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#RuntimeRep"><span class="hs-identifier hs-type">RuntimeRep</span></a></span><span class="hs-special">)</span><span class="hs-operator">.</span><span> </span><span class="hs-keyword">forall</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679538312"><span class="annot"><a href="#local-6989586621679538312"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#TYPE"><span class="hs-identifier hs-type">TYPE</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538313"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span class="hs-operator">.</span><span>
</span><span id="line-47"></span><span>                          </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538312"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-48"></span><span id="errorWithoutStackTrace"><span class="annot"><span class="annottext">errorWithoutStackTrace :: forall a. [Char] -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var hs-var">errorWithoutStackTrace</span></a></span></span><span> </span><span id="local-6989586621679538296"><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679538296"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SomeException -&gt; a
forall b a. b -&gt; a
</span><a href="../../ghc-prim/src/GHC.Prim.html#raise%23"><span class="hs-identifier hs-var">raise#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; SomeException
</span><a href="GHC.Exception.html#errorCallException"><span class="hs-identifier hs-var">errorCallException</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><a href="#local-6989586621679538296"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span class="hs-comment">-- Note [Errors in base]</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-53"></span><span class="hs-comment">-- As of base-4.9.0.0, `error` produces a stack trace alongside the</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- error message using the HasCallStack machinery. This provides</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- a partial stack trace, containing the call-site of each function</span><span>
</span><span id="line-56"></span><span class="hs-comment">-- with a HasCallStack constraint.</span><span>
</span><span id="line-57"></span><span class="hs-comment">--</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- In base, however, the only functions that have such constraints are</span><span>
</span><span id="line-59"></span><span class="hs-comment">-- error and undefined, so the stack traces from partial functions in</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- base will never contain a call-site in user code. Instead we'll</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- usually just get the actual call to error. Base functions already</span><span>
</span><span id="line-62"></span><span class="hs-comment">-- have a good habit of providing detailed error messages, including the</span><span>
</span><span id="line-63"></span><span class="hs-comment">-- name of the offending partial function, so the partial stack-trace</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- does not provide any extra information, just noise. Thus, we export</span><span>
</span><span id="line-65"></span><span class="hs-comment">-- the callstack-aware error, but within base we use the</span><span>
</span><span id="line-66"></span><span class="hs-comment">-- errorWithoutStackTrace variant for more hygienic error messages.</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-comment">-- | A special case of 'error'.</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- It is expected that compilers will recognize this and insert error</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- messages which are more appropriate to the context in which 'undefined'</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- appears.</span><span>
</span><span id="line-73"></span><span class="annot"><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-type">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679538310"><span class="annot"><a href="#local-6989586621679538310"><span class="hs-identifier hs-type">r</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#RuntimeRep"><span class="hs-identifier hs-type">RuntimeRep</span></a></span><span class="hs-special">)</span><span class="hs-operator">.</span><span> </span><span class="hs-keyword">forall</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679538309"><span class="annot"><a href="#local-6989586621679538309"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#TYPE"><span class="hs-identifier hs-type">TYPE</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679538310"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span class="hs-operator">.</span><span>
</span><span id="line-74"></span><span>             </span><span class="annot"><a href="GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679538309"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-75"></span><span id="undefined"><span class="annot"><span class="annottext">undefined :: forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var hs-var">undefined</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">[Char] -&gt; a
forall a. HasCallStack =&gt; [Char] -&gt; a
</span><a href="GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;Prelude.undefined&quot;</span></span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-comment">-- | Used for compiler-generated error message;</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- encoding saves bytes of string junk.</span><span>
</span><span id="line-79"></span><span id="local-6989586621679538307"><span class="annot"><a href="GHC.Err.html#absentErr"><span class="hs-identifier hs-type">absentErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679538307"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-80"></span><span id="absentErr"><span class="annot"><span class="annottext">absentErr :: forall a. a
</span><a href="GHC.Err.html#absentErr"><span class="hs-identifier hs-var hs-var">absentErr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; a
forall a. [Char] -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var">errorWithoutStackTrace</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;Oops! The program has entered an `absent' argument!\n&quot;</span></span><span>
</span><span id="line-81"></span></pre></body></html>